package filepro.file;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

/**
 * @author small瑞
 */
public class FileTest {
    public static void main(String[] args) throws IOException {
        String path = "G:/IO/牵丝戏.txt";
        String pre = "G:/IO";
        File file = new File(path);
        File file1 = new File(pre);

        System.out.println(file.canExecute());
        System.out.println(file.canRead());
        System.out.println(file.canWrite());

        /**
         * file比较的是路径字符串的compareTo
         */
        System.out.println(file.compareTo(file1));
        System.out.println(path.compareTo(pre));

        System.out.println("------------------");

        System.out.println(file.isFile());
        System.out.println(file.isDirectory());
        System.out.println(file.isAbsolute());
        System.out.println(file.isHidden());

        System.out.println("--------------------");

        System.out.println(Arrays.toString(file1.list()));
        File file2 = new File(pre , "山海经");
        System.out.println(file2.exists());
        File file3 = new File("G:/IO/山海经");
        System.out.println(file3.mkdir());


        System.out.println("---------------------");

        InputStream inputStream = new FileInputStream("G:\\IO\\山海经/南山开篇.txt");

        System.out.println(inputStream.available());

        String cur;
        char info;
        int j;
        byte[] bytes = new byte[2<<3];
        while((j=inputStream.read(bytes))!=-1){
            System.out.println(new String(bytes,0,j));
        }
        inputStream.close();



    }
}
